<?php
require 'lib/init.php';
if(empty($_POST)){
    require 'view/admin/catadd.html';
}else{
    if(empty(trim($_POST['catname']))){
        echo '栏目不能为空';
        header('refresh:2;url=catadd.php');
        exit();
    }
    mQuery("set names utf8");
//    echo "insert into cat(cat_name) values('$_POST[catname]');";
//    $res=mQuery("insert into cat(cat_name) values('$_POST[catname]');");
    $data['cat_name']=$_POST['catname'];
    $res=mExec('cat',$data);
    if($res){
//        echo '栏目插入成功';
//        header('refresh:2;url=catlist.php');
        success('栏目插入成功');
    }else{
//        echo '栏目插入失败';
//        header('refresh:2;url=catadd.php');
        error('栏目插入失败');
    }
}
